package com.gzx.plugin.website.articles.vo;

import cn.hutool.extra.spring.SpringUtil;
import com.fhs.core.trans.anno.Trans;
import com.fhs.core.trans.constant.TransType;
import com.fhs.trans.service.impl.DictionaryTransService;
import com.gzx.plugin.website.articles.entity.GzxWebsiteArticles;
import com.gzx.plugin.website.configs.service.GzxWebsiteConfigService;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.annotation.Resource;
import lombok.Data;
import lombok.EqualsAndHashCode;
import vip.xiaonuo.common.pojo.CommonEntity;

import java.util.Map;

/**
 * @author zjt
 * @description
 * @date 2025/4/22 14:05
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = GzxWebsiteArticles.class)
public class GzxWebsiteArticlesVo extends CommonEntity {

    @Resource
    private DictionaryTransService dictionaryTransService;

    private String id;

    private String configId;

    private String companyName;

    @Trans(type = TransType.DICTIONARY, key = "WebsiteArticlesType")
    private String type;

    private String title;

    private String content;


    @Override
    public Map<String, Object> getTransMap() {
        Map<String, Object> totalMap = super.getTransMap();
        GzxWebsiteConfigService websiteConfigService = SpringUtil.getBean(GzxWebsiteConfigService.class);
        if (this.configId != null) {
            this.companyName = websiteConfigService.getCompanyDict().get(this.configId);
            totalMap.put("companyName", this.companyName);
        }
        return totalMap;
    }

}
